<!--侧边栏-->

<template>
    <div class="sidebar">
<!--        指向路由地址-->
        <el-menu router  class="el-menu-vertical-demo"   theme="light" >
            <el-menu-item index="index">
                <span>&nbsp;主&ensp;&ensp;页</span>
            </el-menu-item>
<!--            遍历权限-->
<!--            <el-menu-item @open="onRoutes" :index="menu.index" v-auth :code="menu.code" v-for="menu in menus11">-->
<!--                <span>{{menu.name}}</span>-->
<!--            </el-menu-item>-->


<!--            ------------------------------------------------------------------------------------------------------>

            <!--            显示没有子菜单的-->
            <el-menu-item @open="onRoutes" v-if="menu.children == null" :index="menu.index" v-auth :code="menu.code" v-for="menu in menus">
                <span>{{menu.name}}</span>
            </el-menu-item>
<!--            显示有子菜单的-->
            <el-submenu :index="menu.index+''" @open="onRoutes"  v-if="menu.children != null"  v-auth  :code="menu.code" v-for="menu in menus">
                <template slot="title">
                    <span>{{ menu.name }}</span>
                </template>
                <el-menu-item  :index="bb.index+''" :code="bb.code" v-auth v-for="bb in menu.children">
                    <template slot="title">
                        <span>{{bb.name}}</span>
                    </template>
                </el-menu-item>
            </el-submenu>


        </el-menu>
    </div>
</template>

<script>
    import Config from 'Config';
    //使用默认的权限
    export default {
        data () {
            return{
                menus2:[
                    {
                        name:"项目管理",
                        index:"organization",
                        code:"account:organization:list",
                        children:[
                            {
                                name:"项目管理儿子",
                                index:"project",
                                code:"account:project:list",
                                children:[
                                    {
                                        name:"项目管理孙子",
                                        index:"222",
                                        code:"account:project:list"
                                    },
                                ]
                            },

                        ]
                    }
                ],
                menus11:[
                    {
                        name:"公告管理",
                        index:"notice",
                        code:"account:notice:list",
                    }, {
                        name:"机构管理",
                        index:"organization",
                        code:"account:organization:list"
                    }, {
                        name:"项目管理",
                        index:"project",
                        code:"account:project:list",
                        children:[
                            {
                                name:"申报管理",
                                index:"projectApplication",
                                code:"account:application:list"
                            },{
                                name:"变更管理",
                                index:"update",
                                code:"account:projectUpdate:list"
                            },{
                                name:"结题管理",
                                index:"concludeApplication",
                                code:"account:conclude:list"
                            }
                        ]
                    },{
                        name:"人员管理",
                        index:"people",
                        code:"system:people:list",
                        children: [
                            {
                                name:"权限管理",
                                index:"permission",
                                code:"account:permission:list"
                            },{
                                name:"角色管理",
                                index:"role",
                                code:"account:role:list"
                            },{
                                name:"用户管理",
                                index:"user",
                                code:"account:user:list"
                            }
                        ]
                    },{
                        name:"系统管理",
                        index:"system",
                        code:"system:*:list",
                        children: [
                            {
                                name:"公告管理",
                                index:"notice",
                                code:"account:notice:list",
                            }, {
                                name:"机构管理",
                                index:"organization",
                                code:"account:organization:list"
                            }, {
                                name:"项目管理",
                                index:"project",
                                code:"account:project:list",
                            }, {
                                name:"申报管理",
                                index:"projectApplication",
                                code:"account:application:list"
                            },{
                                name:"变更管理",
                                index:"update",
                                code:"account:projectUpdate:list"
                            },{
                                name:"结题管理",
                                index:"concludeApplication",
                                code:"account:conclude:list"
                            },{
                                name:"数据字典",
                                index:"dict",
                                code:"system:dictType:list"
                            },
                            {
                                name:"权限管理",
                                index:"permission",
                                code:"account:permission:list"
                            },{
                                name:"角色管理",
                                index:"role",
                                code:"account:role:list"
                            },{
                                name:"用户管理",
                                index:"user",
                                code:"account:user:list"
                            }
                        ]
                    }
                ],
                menus:[]
            }
        },
        created: function () {
            this.$axios.get(this.$config.SYSTEM_HOST + "/permission/per_code").then((res) => {
                console.log(res.data.data)
                console.log("======================")
                this.menus = res.data.data
                //this.$router.push("/index");//跳转页面
            });
        },
        //计算属性
        computed:{
            onRoutes(){//返回当前路由地址
                return this.$route.path.replace('/','');
            }
        }
    }
</script>

<style scoped>
    .sidebar{
        display: block;
        position: absolute;
        width: 140px;
        left: 0;
        top: 70px;
        bottom:0;
        background: #2E363F;
    }
    .sidebar > ul {
        height:100%;
    }
</style>
